<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>apk管理</title>
<link rel="stylesheet" href="/scriptZIP/layui.min.css">
	<link rel="stylesheet" href="../css/common2.css">
	<link rel="stylesheet" href="../css/layui.css" />
	<style>
		.layui-row {
			margin-top: 50px;
		}
	</style>
</head>

<body>
	
	<div class="layui-row" id="vue-root">
		<div></div>
		<div class="layui-col-md6 layui-col-md-offset3">

			<div class="layui-form-item">
				<label class="layui-form-label">版本号</label>
				<div class="layui-input-block">
					<input name="apkName" v-validate="'required'" autocomplete="off" placeholder="请输入版本号"
						class="layui-input name" v-model="item.name">

				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">versionCode</label>
				<div class="layui-input-block">
					<input name="apkCode" v-validate="'required'" autocomplete="off" placeholder="请输入versionCode"
						class="layui-input tag" v-model="item.code">

				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">描述</label>
				<div class="layui-input-block">
					<textarea placeholder="请输入描述" name="feature" data-vv-as="描述" class="layui-textarea text"
						v-model="item.remark"></textarea>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">文件上传</label>
				<div class="layui-input-block">
					<form id="form" method="post" ref="form" enctype="multipart/form-data">
						<input type="file" id="File1" name="file" accept=".apk" @change="upload" ref="file">
					</form>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">强制更新</label>
				<div class="layui-input-block">
					<input type="checkbox" name="switch" lay-skin="switch" v-model="item.forced">
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<div class="offer" @click="submit">立即提交</div>
					<div class="return" onclick="history.back()">取消</div>
				</div>
			</div>
		</div>
	</div>

	<script src="/scriptZIP/qs.min.js"></script>
	<script src="/scriptZIP/vue.min.js"></script>
	
	
	<script src="/scriptZIP/axios.min.js"></script>

	<script src="/js/common.js"></script>


	<script>
		var app = new Vue({
			el: '#vue-root',
			data: {
				item: {},
				url: '/pc/apk'
			},
			methods: {
				upload: function () {
					axios.post('/pc/upload/apk',
						new FormData(this.$refs.form)).then(function (res) {
							this.item.file = res.data.data;
							alert('上传成功');
						}.bind(this));
				},
				submit: function () {
					if (!this.item.file) {
						alert('还没上传文件');
						return;
					}
					axios.put('/pc/apk/' + params().id, this.item).then(function (res) {
						alert('成功');
						history.back();
					}.bind(this));
				}
			}
		});

	</script>
</body>

</html>